﻿using System.Net;
using ZeroMQCommon;

namespace ZeroMQSender
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, ZeroMQSender!");
            
            Task.Run(() =>
            {
                int imageIndex = 0;
                Parallel.For(0, 10, i =>
                {
                    for (int j = 0; j < 10; j++)
                    {
                        var st = DateTime.Now;
                        string imageId = $"IMG_{DateTime.UtcNow:HHmmssfff}_{imageIndex++}";
                        byte[] fakeImage = new byte[100 * 1024 * 1024]; // 100MB
                        //new Random().NextBytes(fakeImage);
                        var rng = new Random(Guid.NewGuid().GetHashCode());
                        rng.NextBytes(fakeImage);
                        ZmqImageSender.SendImage(fakeImage, imageId, GlobalConsts.ZMQ_IMAGE_SENDER_ADDRESS);
                        Console.WriteLine($"[SEND] ThreadId:{Thread.CurrentThread.ManagedThreadId} {imageId},Take {(DateTime.Now - st).TotalMilliseconds} ms");
                        Thread.Sleep(500); // Simulate 10fps per sender
                    }
                });
            });

            Task.Delay(Timeout.Infinite).Wait(); // Keep the application running
        }
    }
}
